import java.util.Scanner;

/**
 * @author: gao
 * @create-date: 2025/4/27 10:09
 */

class ListNode {
    int val;
    ListNode next;

    public ListNode(int val) {
        this.val = val;
    }
}

public class Solution {
    public void deleteNode(ListNode node) {
        // 将当前节点的值设置为下一个节点的值
        node.val = node.next.val;
        // 将当前节点的下一个节点指向下一个节点的下一个节点
        node.next = node.next.next;
    }



    private static ListNode createList(int[] nums) {
        if (nums == null || nums.length == 0) {
            return null;
        }
        ListNode head = new ListNode(nums[0]);
        ListNode cur = head;
        for (int i = 1; i < nums.length; i++) {
            cur.next = new ListNode(nums[i]);
            cur = cur.next;
        }
        return head;
    }

    private static void printList(ListNode head) {
        ListNode cur = head;
        while (cur != null) {
            System.out.print(cur.val + " ");
            cur = cur.next;
        }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }
            int node = in.nextInt();
            ListNode head = createList(nums);
            ListNode cur = head;
            for (int i = 0; i < node - 1; i++) {
                cur = cur.next;
            }

            Solution solution = new Solution();
            solution.deleteNode(cur);
            printList(head);
        }
    }
}